package tg.webclient.rj.beans.mtassign;

import java.io.PrintStream;
import java.rmi.RemoteException;
import java.util.Vector;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.util.MXException;
import psdi.webclient.system.beans.DataBean;
import psdi.webclient.system.beans.MultiselectDataBean;
import psdi.webclient.system.controller.AppInstance;
import psdi.webclient.system.controller.Utility;
import psdi.webclient.system.controller.WebClientEvent;

public class MultiSectMTPers extends MultiselectDataBean
{
  public synchronized int execute()
    throws MXException, RemoteException
  {
    selectok();
    return super.execute();
  }

  public synchronized int selectok() throws MXException, RemoteException {
    MboSetRemote mboset = this.app.getDataBean("Mulsel_table").getMboSet();
    MboRemote mbo = this.app.getDataBean("WTPRS_TABLE").getParent().getMbo();
    System.out.println("=========APP=11111======");
    if (!mboset.isEmpty()) {
      System.out.println("=========APP==2222=====");
      System.out.println("=========WTASSIGNID=======" + mbo.getInt("WTASSIGNID"));
      if (mbo.getInt("WTASSIGNID") > 0) {
        Vector vec = mboset.getSelection();
        System.out.println("=========vec==33=====" + vec.size());
        if ((vec != null) && (vec.size() > 0)) {
          for (int i = 0; i < vec.size(); i++) {
            MboRemote wtprsmbo = (MboRemote)vec.elementAt(i);
            wtprsmbo.setValue("WTASSIGNID", mbo.getInt("WTASSIGNID"));
          }
        }
      }
    }
    System.out.println("=========APP=======" + mbo.getThisMboSet().getApp());
    this.app.getDataBean("Mulsel_table").refreshTable();
    this.app.getDataBean("Mulsel_table").reloadTable();
    this.app.getAppBean().refreshTable();
    this.app.getAppBean().reloadTable();
    Utility.sendEvent(new WebClientEvent("dialogclose", this.app.getCurrentPageId(), null, this.sessionContext));

    return 1;
  }
}